﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pseudogenerator.Common.Generators.Core
{
    public abstract partial class MethodBase
    {
        #region Campos

        private bool Started = false;
        protected uint ActualIndex = 0;
        private uint _ActualValue = 0;
        public uint ActualValue
        {
            get
            {
                return _ActualValue;
            }
            private set
            {
                _ActualValue = value;
            }
        }

        #endregion

        #region Propiedades

        /// <summary>
        /// Semilla
        /// </summary>
        public uint x0 { get; set; }

        /// <summary>
        /// Modulo
        /// </summary>
        public uint m { get; set; }

        #endregion

        #region Implementaciones de metodos heredados

        public abstract bool CanGenerateNext { get; }
        public abstract uint GetNextValue();
        public abstract List<RandomNumber> GetFullList();

        #endregion

        #region Metodos

        public void ResetActualValue()
        {
            ActualIndex = 0;
            ActualValue = 0;
            Started = false;
        }

        public uint Next()
        {
            if (CanGenerateNext)
            {
                if (ActualValue == 0 && !Started)
                {
                    ActualValue = x0;
                    Started = true;
                    ActualIndex = 0;
                    return ActualValue;
                }
                ActualIndex++;
                ActualValue = GetNextValue();

                return ActualValue;
            }
            return x0;
        }

        #endregion
    }
}
